﻿<Window x:Class="ResourceBlender_Express.WinAddTemplate"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:loc="clr-namespace:ResourceBlender_Express"
    xmlns:validators="clr-namespace:ResourceBlender_Express.Validators"
    Title="Add Template"
    MinHeight="400" Height="650" MinWidth="300" Width="500"
    Initialized="Window_Initialized"
    WindowStartupLocation="CenterOwner" SizeToContent="Height"
    Style="{StaticResource {x:Type Window}}" Icon="/ResourceBlender-Express;component/Resources/images/resourceblender.ico">
    <Window.CommandBindings>
        <CommandBinding Command="loc:ResourceBlenderCommands.OpenFullEditor" Executed="ShowFullEditor" />
        <CommandBinding Command="loc:ResourceBlenderCommands.InsertTag" Executed="InsertTag" CanExecute="CanExecuteInsertTag" />
        <CommandBinding Command="ApplicationCommands.Help" Executed="ShowHelp" />
        <CommandBinding Command="ApplicationCommands.Close" Executed="CloseWindow" />
        <CommandBinding Command="ApplicationCommands.Save" Executed="Save" />
    </Window.CommandBindings>
    <DockPanel LastChildFill="True">
        <Menu DockPanel.Dock="Top">
            <MenuItem Header="_File" HorizontalAlignment="Left" HorizontalContentAlignment="Left">
                <MenuItem Header="E_xit" Command="ApplicationCommands.Close" />
            </MenuItem>
            <MenuItem Header="_Insert Tag">
                <MenuItem Command="loc:ResourceBlenderCommands.InsertTag" CommandParameter="LanguageCode" Header="Language _Code" />
                <MenuItem Command="loc:ResourceBlenderCommands.InsertTag" CommandParameter="Bundle" Header="_Bundle Name" />
                <MenuItem Command="loc:ResourceBlenderCommands.InsertTag" CommandParameter="Element" Header="_Element Name" />
                <MenuItem Command="loc:ResourceBlenderCommands.InsertTag" CommandParameter="Translation" Header="_Translation" />
            </MenuItem>
            <MenuItem Header="_Help">
                <MenuItem Header="Using Templates" Command="ApplicationCommands.Help" />
            </MenuItem>
        </Menu>

        <StackPanel DockPanel.Dock="Bottom" Margin="6" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Center">
            <Button x:Name="btnSave" MinWidth="70" IsDefault="True" Command="ApplicationCommands.Save">Save</Button>
            <Button x:Name="btnCancel" MinWidth="70" IsCancel="True" Command="ApplicationCommands.Close" Margin="2,2,0,2">Cancel</Button>
        </StackPanel>

        <DockPanel DockPanel.Dock="Top" LastChildFill="True" Grid.IsSharedSizeScope="True">          
            <DockPanel DockPanel.Dock="Top" LastChildFill="True" HorizontalAlignment="Stretch" Width="Auto">
                <ToolBar DockPanel.Dock="Right" BorderThickness="0,0,1,1">
                    <loc:ImageButton x:Uid="loc:ImageButton_1" Command="ApplicationCommands.Help" Text="Help on resource templates" Image="Resources/images/question_16.png" ShowText="False" ToolTip="Help on resource templates" Style="{StaticResource ToolBarButton}" />
                </ToolBar>
                <ToolBar DockPanel.Dock="Left" BorderThickness="1,0,0,1">
                    <loc:ImageButton x:Uid="loc:ImageButton_2" Command="loc:ResourceBlenderCommands.InsertTag" CommandParameter="LanguageCode" Text="Insert Language Code" Image="Resources/images/language_code_16.png" ShowText="False" ToolTip="Insert the name of the current Resource Bundle" Style="{StaticResource ToolBarButton}" />
                    <loc:ImageButton x:Uid="loc:ImageButton_3" Command="loc:ResourceBlenderCommands.InsertTag" CommandParameter="Bundle" Text="Insert Bundle Name" Image="Resources/images/bundle_16.png" ShowText="False" ToolTip="Insert the name of the current Resource Bundle" Style="{StaticResource ToolBarButton}" />
                    <loc:ImageButton x:Uid="loc:ImageButton_4" Command="loc:ResourceBlenderCommands.InsertTag" CommandParameter="Element" Text="Insert Element Name" Image="Resources/images/puzzle_16.png" ShowText="False" ToolTip="Insert the name of the current Resource Bundle" Style="{StaticResource ToolBarButton}" />
                    <loc:ImageButton x:Uid="loc:ImageButton_5" Command="loc:ResourceBlenderCommands.InsertTag" CommandParameter="Translation" Text="Insert Translation" Image="Resources/images/translation_16.png" ShowText="False" ToolTip="Insert the name of the current Resource Bundle" Style="{StaticResource ToolBarButton}" />
                </ToolBar>
            </DockPanel>

            <Grid DockPanel.Dock="Top" Margin="6">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="labels" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="*" />
                    <RowDefinition Height="160" />
                </Grid.RowDefinitions>

                <Label Grid.Row="0" Grid.Column="0">Template Name</Label>
                <TextBox x:Name="txtName" Grid.Row="0" Grid.Column="1">
                    <TextBox.Text>
                        <Binding Path="Name" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
                            <Binding.ValidationRules>
                                <validators:StringValidationRule x:Uid="validators:StringValidationRule_1" MinimumLength="0" MaximumLength="255" ErrorMessage="The template name must be entered" />
                            </Binding.ValidationRules>
                        </Binding>
                    </TextBox.Text>
                </TextBox>

                <GroupBox Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Header="Template Definition">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" SharedSizeGroup="labels" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="4*" />
                            <RowDefinition Height="4*" />
                            <RowDefinition Height="2*" />
                            <RowDefinition Height="Auto" />
                        </Grid.RowDefinitions>

                        <Label Grid.Row="0" Grid.Column="0" ToolTip="The format to use for each bundle's filename">Filename</Label>
                        <TextBox x:Name="txtFileName" Grid.Row="0" Grid.Column="1" ToolTip="The format to use for each bundle's filename">
                            <TextBox.Text>
                                <Binding Path="FileName" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
                                    <Binding.ValidationRules>
                                        <validators:StringValidationRule x:Uid="validators:StringValidationRule_2" MinimumLength="0" MaximumLength="255" ErrorMessage="You must enter the format used to generate file names" />
                                    </Binding.ValidationRules>
                                </Binding>
                            </TextBox.Text>
                        </TextBox>
                        <loc:ImageButton x:Uid="loc:ImageButton_6" Grid.Row="1" Grid.Column="2" Image="Resources/images/expand_16.png" ShowText="False" ToolTip="Open the full editor for the filename" Margin="1,1,0,1" VerticalAlignment="Top"
                                         Command="loc:ResourceBlenderCommands.OpenFullEditor" CommandTarget="{Binding ElementName=txtFileName}" />
                        
                        <Label Grid.Row="1" Grid.Column="0" ToolTip="Text prepended to the start of each bundle">File Start</Label>
                        <TextBox x:Name="txtFileStart" Grid.Row="1" Grid.Column="1" ToolTip="Text prepended to the start of each bundle" Text="{Binding FileStart,Mode=Twoway,UpdateSourceTrigger=PropertyChanged}" AcceptsReturn="True" />
                        <loc:ImageButton x:Uid="loc:ImageButton_7" Grid.Row="0" Grid.Column="2" Image="Resources/images/expand_16.png" ShowText="False" ToolTip="Open the full editor for the file start" Margin="1,1,0,1" VerticalAlignment="Top"
                                         Command="loc:ResourceBlenderCommands.OpenFullEditor" CommandTarget="{Binding ElementName=txtFileStart}" />
                        
                        <Label Grid.Row="2" Grid.Column="0" ToolTip="Text to append to the end of each bundle">File End</Label>
                        <TextBox x:Name="txtFileEnd" Grid.Row="2" Grid.Column="1" ToolTip="Text to append to the end of each bundle" Text="{Binding FileEnd,Mode=Twoway,UpdateSourceTrigger=PropertyChanged}" AcceptsReturn="True" />
                        <loc:ImageButton x:Uid="loc:ImageButton_8" Grid.Row="2" Grid.Column="2" Image="Resources/images/expand_16.png" ShowText="False" ToolTip="Open the full editor for the file end" Margin="1,1,0,1" VerticalAlignment="Top"
                                         Command="loc:ResourceBlenderCommands.OpenFullEditor" CommandTarget="{Binding ElementName=txtFileEnd}" />
                        
                        <Label Grid.Row="3" Grid.Column="0" ToolTip="The format for each element">Element</Label>
                        <TextBox x:Name="txtFileLine" Grid.Row="3" Grid.Column="1"  ToolTip="The format for each element" AcceptsReturn="True">
                            <TextBox.Text>
                                <Binding Path="FileLine" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
                                    <Binding.ValidationRules>
                                        <validators:StringValidationRule x:Uid="validators:StringValidationRule_3" MinimumLength="0" MaximumLength="255" ErrorMessage="You must enter the format for each element" />
                                    </Binding.ValidationRules>
                                </Binding>
                            </TextBox.Text>
                        </TextBox>
                        <loc:ImageButton x:Uid="loc:ImageButton_9" Grid.Row="3" Grid.Column="2" Image="Resources/images/expand_16.png" ShowText="False" ToolTip="Open the full editor for the element format" Margin="1,1,0,1" VerticalAlignment="Top"
                                         Command="loc:ResourceBlenderCommands.OpenFullEditor" CommandTarget="{Binding ElementName=txtFileLine}" />
                    </Grid>
                </GroupBox>

                <GroupBox Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="2" Header="Preview">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" SharedSizeGroup="labels" />
                            <ColumnDefinition Width="*" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="Auto" />
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>
                        
                        <Label Grid.Row="0" Grid.Column="0">Filename</Label>
                        <TextBlock Grid.Row="0" Grid.Column="1" x:Name="prvFilename" VerticalAlignment="Center" />
                        
                        <ScrollViewer Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2">
                            <TextBox x:Name="prvContents" Grid.Row="1" Grid.Column="1" IsEnabled="False" />
                        </ScrollViewer>
                    </Grid>
                </GroupBox>
            </Grid>
        </DockPanel>
    </DockPanel>
</Window>
